

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>geoslurp.dataset.PSMSL &mdash; geoslurp v1.1.0 documentation</title>
  

  
  
    <link rel="shortcut icon" href="../../../_static/favicon.ico"/>
  
  
  

  

  
  
    

  

  
  
    <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" />
  

  

  
        <link rel="index" title="Index"
              href="../../../genindex.html"/>
        <link rel="search" title="Search" href="../../../search.html"/>
    <link rel="top" title="geoslurp v1.1.0 documentation" href="../../../index.html"/>
        <link rel="up" title="Module code" href="../../index.html"/> 

  
  <script src="../../../_static/js/modernizr.min.js"></script>

</head>

<body class="wy-body-for-nav" role="document">

   
  <div class="wy-grid-for-nav">

    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search">
          

          
            <a href="../../../index.html" class="icon icon-home"> geoslurp
          

          
          </a>

          
            
            
              <div class="version">
                1.1.0
              </div>
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <p class="caption"><span class="caption-text">Contents:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../introduction.html">An introduction to Geoslurp</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../installation.html">Installation of the geoslurp package and setting up the PostgreSQL instance</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../confsettings.html">Configuration</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../examples.html">Tutorial</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../reference.html">Reference Documentation</a></li>
</ul>

            
          
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" role="navigation" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../../index.html">geoslurp</a>
        
      </nav>


      
      <div class="wy-nav-content">
        <div class="rst-content">
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../../index.html">Docs</a> &raquo;</li>
        
          <li><a href="../../index.html">Module code</a> &raquo;</li>
        
      <li>geoslurp.dataset.PSMSL</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <h1>Source code for geoslurp.dataset.PSMSL</h1><div class="highlight"><pre>
<span></span><span class="c1"># This file is part of geoslurp.</span>
<span class="c1"># geoslurp is free software; you can redistribute it and/or</span>
<span class="c1"># modify it under the terms of the GNU Lesser General Public</span>
<span class="c1"># License as published by the Free Software Foundation; either</span>
<span class="c1"># version 3 of the License, or (at your option) any later version.</span>

<span class="c1"># geoslurp is distributed in the hope that it will be useful,</span>
<span class="c1"># but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<span class="c1"># MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU</span>
<span class="c1"># Lesser General Public License for more details.</span>

<span class="c1"># You should have received a copy of the GNU Lesser General Public</span>
<span class="c1"># License along with Frommle; if not, write to the Free Software</span>
<span class="c1"># Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA</span>

<span class="c1"># Author Roelof Rietbroek (roelof@geod.uni-bonn.de), 2018</span>
<span class="kn">from</span> <span class="nn">geoslurp.dataset</span> <span class="k">import</span> <span class="n">DataSet</span>
<span class="kn">from</span> <span class="nn">sqlalchemy.ext.declarative</span> <span class="k">import</span> <span class="n">declared_attr</span><span class="p">,</span> <span class="n">as_declarative</span>
<span class="kn">from</span> <span class="nn">sqlalchemy</span> <span class="k">import</span> <span class="n">MetaData</span>
<span class="kn">from</span> <span class="nn">sqlalchemy</span> <span class="k">import</span> <span class="n">Column</span><span class="p">,</span><span class="n">Integer</span><span class="p">,</span><span class="n">String</span><span class="p">,</span> <span class="n">Boolean</span><span class="p">,</span><span class="n">Float</span>
<span class="kn">from</span> <span class="nn">sqlalchemy.dialects.postgresql</span> <span class="k">import</span> <span class="n">TIMESTAMP</span><span class="p">,</span> <span class="n">JSONB</span>
<span class="kn">from</span> <span class="nn">geoslurp.datapull.http</span> <span class="k">import</span> <span class="n">Uri</span> <span class="k">as</span> <span class="n">http</span>
<span class="kn">from</span> <span class="nn">geoalchemy2.types</span> <span class="k">import</span> <span class="n">Geography</span>
<span class="kn">from</span> <span class="nn">geoalchemy2.elements</span> <span class="k">import</span> <span class="n">WKBElement</span>
<span class="kn">from</span> <span class="nn">datetime</span> <span class="k">import</span> <span class="n">datetime</span><span class="p">,</span><span class="n">timedelta</span>
<span class="kn">from</span> <span class="nn">geoslurp.tools.time</span> <span class="k">import</span> <span class="n">dt2yearlyinterval</span><span class="p">,</span><span class="n">dt2monthlyinterval</span><span class="p">,</span><span class="n">decyear2dt</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">from</span> <span class="nn">zipfile</span> <span class="k">import</span> <span class="n">ZipFile</span>
<span class="kn">from</span> <span class="nn">osgeo</span> <span class="k">import</span> <span class="n">ogr</span>
<span class="kn">from</span> <span class="nn">geoslurp.config.slurplogger</span> <span class="k">import</span> <span class="n">slurplogger</span>
<span class="kn">from</span> <span class="nn">geoslurp.config.catalogue</span> <span class="k">import</span> <span class="n">geoslurpCatalogue</span>


<span class="n">scheme</span><span class="o">=</span><span class="s2">&quot;oceanobs&quot;</span>

<span class="n">geoPointtype</span> <span class="o">=</span> <span class="n">Geography</span><span class="p">(</span><span class="n">geometry_type</span><span class="o">=</span><span class="s2">&quot;POINTZ&quot;</span><span class="p">,</span> <span class="n">srid</span><span class="o">=</span><span class="s1">&#39;4326&#39;</span><span class="p">,</span> <span class="n">spatial_index</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span><span class="n">dimension</span><span class="o">=</span><span class="mi">3</span><span class="p">)</span>

<span class="c1">#define a declarative baseclass for spherical harmonics gravity  data</span>
<span class="nd">@as_declarative</span><span class="p">(</span><span class="n">metadata</span><span class="o">=</span><span class="n">MetaData</span><span class="p">(</span><span class="n">schema</span><span class="o">=</span><span class="n">scheme</span><span class="p">))</span>
<span class="k">class</span> <span class="nc">PSMSLTBase</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
    <span class="nd">@declared_attr</span>
    <span class="k">def</span> <span class="nf">__tablename__</span><span class="p">(</span><span class="bp">cls</span><span class="p">):</span>
        <span class="c1">#strip of the &#39;Table&#39; from the class name</span>
        <span class="k">return</span> <span class="bp">cls</span><span class="o">.</span><span class="vm">__name__</span><span class="p">[:</span><span class="o">-</span><span class="mi">5</span><span class="p">]</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">&quot;-&quot;</span><span class="p">,</span><span class="s2">&quot;_&quot;</span><span class="p">)</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span>
    <span class="nb">id</span> <span class="o">=</span> <span class="n">Column</span><span class="p">(</span><span class="n">Integer</span><span class="p">,</span> <span class="n">primary_key</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
    <span class="n">statname</span><span class="o">=</span><span class="n">Column</span><span class="p">(</span><span class="n">String</span><span class="p">)</span>
    <span class="n">lastupdate</span><span class="o">=</span><span class="n">Column</span><span class="p">(</span><span class="n">TIMESTAMP</span><span class="p">)</span>
    <span class="n">tstart</span><span class="o">=</span><span class="n">Column</span><span class="p">(</span><span class="n">TIMESTAMP</span><span class="p">,</span><span class="n">index</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
    <span class="n">tend</span><span class="o">=</span><span class="n">Column</span><span class="p">(</span><span class="n">TIMESTAMP</span><span class="p">,</span><span class="n">index</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
    <span class="n">ndat</span><span class="o">=</span><span class="n">Column</span><span class="p">(</span><span class="n">Integer</span><span class="p">)</span>
    <span class="n">countrycode</span><span class="o">=</span><span class="n">Column</span><span class="p">(</span><span class="n">String</span><span class="p">)</span>
    <span class="n">formerid</span><span class="o">=</span><span class="n">Column</span><span class="p">(</span><span class="n">String</span><span class="p">)</span>
    <span class="n">data</span><span class="o">=</span><span class="n">Column</span><span class="p">(</span><span class="n">JSONB</span><span class="p">)</span>
    <span class="n">geom</span><span class="o">=</span><span class="n">Column</span><span class="p">(</span><span class="n">geoPointtype</span><span class="p">)</span>

<div class="viewcode-block" id="PSMSLBase"><a class="viewcode-back" href="../../../reference/geoslurp.dataset.html#geoslurp.dataset.PSMSL.PSMSLBase">[docs]</a><span class="k">class</span> <span class="nc">PSMSLBase</span><span class="p">(</span><span class="n">DataSet</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Base class to store RLR/MET annual and monthly data&quot;&quot;&quot;</span>
    <span class="n">url</span><span class="o">=</span><span class="kc">None</span>
    <span class="n">typ</span><span class="o">=</span><span class="kc">None</span>
    <span class="n">freq</span><span class="o">=</span><span class="kc">None</span>
    <span class="n">scheme</span><span class="o">=</span><span class="n">scheme</span>
    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">dbconn</span><span class="p">):</span>
        <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">dbconn</span><span class="p">)</span>
        <span class="n">PSMSLTBase</span><span class="o">.</span><span class="n">metadata</span><span class="o">.</span><span class="n">create_all</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">db</span><span class="o">.</span><span class="n">dbeng</span><span class="p">,</span> <span class="n">checkfirst</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>

<div class="viewcode-block" id="PSMSLBase.pull"><a class="viewcode-back" href="../../../reference/geoslurp.dataset.html#geoslurp.dataset.PSMSL.PSMSLBase.pull">[docs]</a>    <span class="k">def</span> <span class="nf">pull</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">http</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">url</span><span class="p">)</span><span class="o">.</span><span class="n">download</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">cacheDir</span><span class="p">())</span>
        <span class="n">zpf</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">cacheDir</span><span class="p">(),</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">basename</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">url</span><span class="p">))</span>
        <span class="c1">#unzip file</span>
        <span class="k">with</span> <span class="n">ZipFile</span><span class="p">(</span><span class="n">zpf</span><span class="p">,</span><span class="s1">&#39;r&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">zp</span><span class="p">:</span>
            <span class="n">zp</span><span class="o">.</span><span class="n">extractall</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">cacheDir</span><span class="p">())</span></div>

<div class="viewcode-block" id="PSMSLBase.register"><a class="viewcode-back" href="../../../reference/geoslurp.dataset.html#geoslurp.dataset.PSMSL.PSMSLBase.register">[docs]</a>    <span class="k">def</span> <span class="nf">register</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>

        <span class="c1">#currently deletes all entries in the table</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">truncateTable</span><span class="p">()</span>

        <span class="c1">#open main index file and read</span>
        <span class="n">zipdir</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">cacheDir</span><span class="p">()</span><span class="o">+</span><span class="s2">&quot;/&quot;</span><span class="o">+</span><span class="bp">self</span><span class="o">.</span><span class="n">typ</span><span class="o">+</span><span class="s2">&quot;_&quot;</span><span class="o">+</span><span class="bp">self</span><span class="o">.</span><span class="n">freq</span>

        <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">zipdir</span><span class="p">,</span><span class="s1">&#39;filelist.txt&#39;</span><span class="p">),</span><span class="s1">&#39;r&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">fid</span><span class="p">:</span>
            <span class="k">for</span> <span class="n">ln</span> <span class="ow">in</span> <span class="n">fid</span><span class="p">:</span>
                <span class="n">lnspl</span><span class="o">=</span><span class="n">ln</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;;&quot;</span><span class="p">)</span>
                <span class="n">lat</span><span class="o">=</span><span class="nb">float</span><span class="p">(</span><span class="n">lnspl</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
                <span class="n">lon</span><span class="o">=</span><span class="nb">float</span><span class="p">(</span><span class="n">lnspl</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span>
                <span class="nb">id</span><span class="o">=</span><span class="nb">int</span><span class="p">(</span><span class="n">lnspl</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
                <span class="n">slurplogger</span><span class="p">()</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s2">&quot;Indexing </span><span class="si">%s</span><span class="s2">&quot;</span><span class="o">%</span><span class="p">(</span><span class="n">lnspl</span><span class="p">[</span><span class="mi">3</span><span class="p">]))</span>

                <span class="n">geoLoc</span><span class="o">=</span><span class="n">ogr</span><span class="o">.</span><span class="n">Geometry</span><span class="p">(</span><span class="n">ogr</span><span class="o">.</span><span class="n">wkbPoint</span><span class="p">)</span>
                <span class="n">geoLoc</span><span class="o">.</span><span class="n">AddPoint</span><span class="p">(</span><span class="n">lon</span><span class="p">,</span><span class="n">lat</span><span class="p">)</span>
                <span class="n">meta</span><span class="o">=</span><span class="p">{</span>
                    <span class="s2">&quot;id&quot;</span><span class="p">:</span><span class="nb">id</span><span class="p">,</span>
                    <span class="s2">&quot;statname&quot;</span><span class="p">:</span><span class="n">lnspl</span><span class="p">[</span><span class="mi">3</span><span class="p">],</span>
                    <span class="s2">&quot;countrycode&quot;</span><span class="p">:</span><span class="n">lnspl</span><span class="p">[</span><span class="mi">4</span><span class="p">],</span>
                    <span class="s2">&quot;formerid&quot;</span><span class="p">:</span><span class="n">lnspl</span><span class="p">[</span><span class="mi">5</span><span class="p">],</span>
                    <span class="s2">&quot;geom&quot;</span><span class="p">:</span><span class="n">WKBElement</span><span class="p">(</span><span class="n">geoLoc</span><span class="o">.</span><span class="n">ExportToWkb</span><span class="p">(),</span><span class="n">srid</span><span class="o">=</span><span class="mi">4326</span><span class="p">,</span><span class="n">extended</span><span class="o">=</span><span class="kc">True</span><span class="p">),</span>
                <span class="p">}</span>

                <span class="c1">#also open data file</span>
                <span class="n">data</span><span class="o">=</span><span class="p">{</span><span class="s2">&quot;time&quot;</span><span class="p">:[],</span><span class="s2">&quot;sl&quot;</span><span class="p">:[]}</span>
                <span class="n">tmin</span><span class="o">=</span><span class="n">datetime</span><span class="o">.</span><span class="n">max</span>
                <span class="n">tmax</span><span class="o">=</span><span class="n">datetime</span><span class="o">.</span><span class="n">min</span>
                <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">zipdir</span><span class="p">,</span><span class="s1">&#39;data&#39;</span><span class="p">,</span><span class="s2">&quot;</span><span class="si">%d</span><span class="s2">.</span><span class="si">%s</span><span class="s2">data&quot;</span><span class="o">%</span><span class="p">(</span><span class="nb">id</span><span class="p">,</span><span class="bp">self</span><span class="o">.</span><span class="n">typ</span><span class="p">)))</span> <span class="k">as</span> <span class="n">dfid</span><span class="p">:</span>
                    <span class="k">for</span> <span class="n">dln</span> <span class="ow">in</span> <span class="n">dfid</span><span class="p">:</span>
                        <span class="n">tyear</span><span class="p">,</span><span class="n">valmm</span><span class="p">,</span><span class="n">dum1</span><span class="p">,</span><span class="n">dum2</span><span class="o">=</span><span class="n">dln</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;;&quot;</span><span class="p">)</span>
                        <span class="n">dt</span><span class="o">=</span><span class="n">decyear2dt</span><span class="p">(</span><span class="nb">float</span><span class="p">(</span><span class="n">tyear</span><span class="p">))</span>
                        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">freq</span> <span class="o">==</span> <span class="s1">&#39;monthly&#39;</span><span class="p">:</span>
                            <span class="n">dstart</span><span class="p">,</span><span class="n">dend</span><span class="o">=</span><span class="n">dt2monthlyinterval</span><span class="p">(</span><span class="n">dt</span><span class="p">)</span>
                        <span class="k">else</span><span class="p">:</span>
                            <span class="c1">#yearly</span>
                            <span class="n">dstart</span><span class="p">,</span><span class="n">dend</span><span class="o">=</span><span class="n">dt2yearlyinterval</span><span class="p">(</span><span class="n">dt</span><span class="p">)</span>
                        <span class="n">tmin</span><span class="o">=</span><span class="nb">min</span><span class="p">(</span><span class="n">dt</span><span class="p">,</span><span class="n">tmin</span><span class="p">)</span>
                        <span class="n">tmax</span><span class="o">=</span><span class="nb">max</span><span class="p">(</span><span class="n">dt</span><span class="p">,</span><span class="n">tmax</span><span class="p">)</span>

                        <span class="n">data</span><span class="p">[</span><span class="s2">&quot;time&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">dt</span><span class="o">.</span><span class="n">isoformat</span><span class="p">())</span>
                        <span class="n">data</span><span class="p">[</span><span class="s2">&quot;sl&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="mf">1e3</span><span class="o">*</span><span class="nb">int</span><span class="p">(</span><span class="n">valmm</span><span class="p">))</span>

                <span class="c1">#open documentation files</span>
                <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">zipdir</span><span class="p">,</span><span class="s1">&#39;docu&#39;</span><span class="p">,</span><span class="s2">&quot;</span><span class="si">%d</span><span class="s2">.txt&quot;</span><span class="o">%</span><span class="p">(</span><span class="nb">id</span><span class="p">)))</span> <span class="k">as</span> <span class="n">docid</span><span class="p">:</span>
                    <span class="n">data</span><span class="p">[</span><span class="s2">&quot;doc&quot;</span><span class="p">]</span><span class="o">=</span><span class="n">docid</span><span class="o">.</span><span class="n">readlines</span><span class="p">()</span>
                <span class="c1">#open auth file</span>
                <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">zipdir</span><span class="p">,</span><span class="s1">&#39;docu&#39;</span><span class="p">,</span><span class="s2">&quot;</span><span class="si">%d</span><span class="s2">_auth.txt&quot;</span><span class="o">%</span><span class="p">(</span><span class="nb">id</span><span class="p">)))</span> <span class="k">as</span> <span class="n">docid</span><span class="p">:</span>
                    <span class="n">data</span><span class="p">[</span><span class="s2">&quot;auth&quot;</span><span class="p">]</span><span class="o">=</span><span class="n">docid</span><span class="o">.</span><span class="n">readlines</span><span class="p">()</span>

                <span class="n">meta</span><span class="p">[</span><span class="s1">&#39;tstart&#39;</span><span class="p">]</span><span class="o">=</span><span class="n">tmin</span>
                <span class="n">meta</span><span class="p">[</span><span class="s2">&quot;tend&quot;</span><span class="p">]</span><span class="o">=</span><span class="n">tmax</span>
                <span class="n">meta</span><span class="p">[</span><span class="s2">&quot;data&quot;</span><span class="p">]</span><span class="o">=</span><span class="n">data</span>

                <span class="bp">self</span><span class="o">.</span><span class="n">addEntry</span><span class="p">(</span><span class="n">meta</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">updateInvent</span><span class="p">()</span></div></div>

<div class="viewcode-block" id="PSMSLClassFactory"><a class="viewcode-back" href="../../../reference/geoslurp.dataset.html#geoslurp.dataset.PSMSL.PSMSLClassFactory">[docs]</a><span class="k">def</span> <span class="nf">PSMSLClassFactory</span><span class="p">(</span><span class="n">clsName</span><span class="p">):</span>
    <span class="n">dum</span><span class="p">,</span><span class="n">typ</span><span class="p">,</span><span class="n">freq</span><span class="o">=</span><span class="n">clsName</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;_&quot;</span><span class="p">)</span>
    <span class="n">url</span><span class="o">=</span><span class="s2">&quot;http://www.psmsl.org/data/obtaining/&quot;</span><span class="o">+</span><span class="n">typ</span><span class="o">+</span><span class="s2">&quot;.&quot;</span><span class="o">+</span><span class="n">freq</span><span class="o">+</span><span class="s2">&quot;.data/&quot;</span><span class="o">+</span><span class="n">typ</span><span class="o">+</span><span class="s2">&quot;_&quot;</span><span class="o">+</span><span class="n">freq</span><span class="o">+</span><span class="s2">&quot;.zip&quot;</span>
    <span class="n">table</span><span class="o">=</span><span class="nb">type</span><span class="p">(</span><span class="n">clsName</span> <span class="o">+</span><span class="s2">&quot;Table&quot;</span><span class="p">,</span> <span class="p">(</span><span class="n">PSMSLTBase</span><span class="p">,),</span> <span class="p">{})</span>
    <span class="k">return</span> <span class="nb">type</span><span class="p">(</span><span class="n">clsName</span><span class="p">,</span> <span class="p">(</span><span class="n">PSMSLBase</span><span class="p">,),</span> <span class="p">{</span><span class="s2">&quot;url&quot;</span><span class="p">:</span> <span class="n">url</span><span class="p">,</span> <span class="s2">&quot;table&quot;</span><span class="p">:</span><span class="n">table</span><span class="p">,</span><span class="s2">&quot;typ&quot;</span><span class="p">:</span><span class="n">typ</span><span class="p">,</span><span class="s2">&quot;freq&quot;</span><span class="p">:</span><span class="n">freq</span><span class="p">})</span></div>


<div class="viewcode-block" id="getPSMSLDsets"><a class="viewcode-back" href="../../../reference/geoslurp.dataset.html#geoslurp.dataset.PSMSL.getPSMSLDsets">[docs]</a><span class="k">def</span> <span class="nf">getPSMSLDsets</span><span class="p">(</span><span class="n">conf</span><span class="p">):</span>
    <span class="n">out</span><span class="o">=</span><span class="p">[]</span>
    <span class="k">for</span> <span class="n">clsName</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;psmsl_rlr_monthly&quot;</span><span class="p">,</span><span class="s2">&quot;psmsl_rlr_annual&quot;</span><span class="p">,</span><span class="s2">&quot;psmsl_met_monthly&quot;</span><span class="p">]:</span>
        <span class="n">out</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">PSMSLClassFactory</span><span class="p">(</span><span class="n">clsName</span><span class="p">))</span>
    <span class="k">return</span> <span class="n">out</span></div>


<span class="n">geoslurpCatalogue</span><span class="o">.</span><span class="n">addDatasetFactory</span><span class="p">(</span><span class="n">getPSMSLDsets</span><span class="p">)</span>
</pre></div>

           </div>
           <div class="articleComments">
            
           </div>
          </div>
          <footer>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright 2020, Roelof Rietbroek.

    </p>
  </div>
  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  


  

    <script type="text/javascript">
        var DOCUMENTATION_OPTIONS = {
            URL_ROOT:'../../../',
            VERSION:'v1.1.0',
            COLLAPSE_INDEX:false,
            FILE_SUFFIX:'.html',
            HAS_SOURCE:  true,
            SOURCELINK_SUFFIX: '.txt'
        };
    </script>
      <script type="text/javascript" src="../../../_static/jquery.js"></script>
      <script type="text/javascript" src="../../../_static/underscore.js"></script>
      <script type="text/javascript" src="../../../_static/doctools.js"></script>

  

  
  
    <script type="text/javascript" src="../../../_static/js/theme.js"></script>
  

  
  
  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.StickyNav.enable();
      });
  </script>
   

</body>
</html>